/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package upeu.cepre.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import upeu.cepre.business.AlumnoManager;
import upeu.cepre.business.DetalleperiodoalumnoManager;
import upeu.cepre.business.DetalleperiodotrabajadorManager;
import upeu.cepre.business.PeriodoManager;
import upeu.cepre.model.Alumno;
import upeu.cepre.model.Detalleperiodoalumno;
import upeu.cepre.model.Detalleperiodotrabajador;

/**
 *
 * @author Elvis Zangetsu
 */
@WebServlet(name = "Controller", urlPatterns = {"/Controller"})
public class Controller extends HttpServlet {

    int opt;

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        opt = Integer.parseInt(request.getParameter("opt"));
 
        switch (opt) {

            case 1: {
                List<Detalleperiodoalumno> listDetalleperiodoalumno = new ArrayList<Detalleperiodoalumno>();
                DetalleperiodoalumnoManager detallePeriodoAlumnoManag = new DetalleperiodoalumnoManager();
                PeriodoManager periodoManag = new PeriodoManager();

                listDetalleperiodoalumno = detallePeriodoAlumnoManag.ReportByPeriodo(periodoManag.PeriodoVigente().getIdPeriodo());
                request.getSession().setAttribute("ListAlumno", listDetalleperiodoalumno);
                response.sendRedirect("modulos/report/ReportAlumno.jsp");
            }
            break;
            case 2: {
                List<Detalleperiodotrabajador> listDetalleperiodotrabajador = new ArrayList<Detalleperiodotrabajador>();
                DetalleperiodotrabajadorManager detalleperiodotrabajadorManag = new DetalleperiodotrabajadorManager();
                PeriodoManager periodoManag = new PeriodoManager();

                listDetalleperiodotrabajador = detalleperiodotrabajadorManag.ReportByPeriodo(periodoManag.PeriodoVigente().getIdPeriodo());
                request.getSession().setAttribute("ListTrabajador", listDetalleperiodotrabajador);
                response.sendRedirect("modulos/report/ReportTrabajador.jsp");
            }
            break;
            case 3: {
                List<Detalleperiodoalumno> listDetalleperiodoalumno = new ArrayList<Detalleperiodoalumno>();
                DetalleperiodoalumnoManager detallePeriodoAlumnoManag = new DetalleperiodoalumnoManager();
                PeriodoManager periodoManag = new PeriodoManager();

                listDetalleperiodoalumno = detallePeriodoAlumnoManag.ReportByPeriodo(periodoManag.PeriodoVigente().getIdPeriodo());
                request.getSession().setAttribute("ListAlumno", listDetalleperiodoalumno);
               
                
                
                
                
                response.sendRedirect("modulos/report/ReportNotas.jsp");
                
                
                
                
                
            }
            break;

            case 4: {
            }
            break;
            case 5: {
            }
            break;
            case 6: {
            }
            break;
            case 7: {
            }
            break;
            case 8: {
            }
            break;
            case 9: {
            }
            break;
            case 10: {
            }
            break;
            case 11: {
            }
            break;
            case 12: {
            }
            break;
            case 13: {
            }
            break;
            case 14: {
            }
            break;
            case 15: {
            }
            break;
            case 16: {
            }
            break;
            case 17: {
            }
            break;
            case 18: {
            }
            break;
            case 19: {
            }
            break;
            case 20: {
            }
            break;


        }




    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
